package org.example.everyday;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * Copyright: 天津联想协同科技有限公司
 * <p>
 *
 * @author anlu
 * @date 2022/4/12 10:29
 */
public class Lc806 {
    public static final int MAX_WIDTH = 100;

    public static void main(String[] args) {
        Lc806 lc806 = new Lc806();

       int[] widths = {4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10};
        String S = "bbbcccdddaaa";
        int[] res = lc806.numberOfLines(widths,S);
        for (int i : res){
            System.out.println(i);
        }
    }

    public int[] numberOfLines(int[] widths, String s) {
        int lines = 1;
        int width = 0;
        for(int i = 0; i < s.length(); i++){
            int need = widths[s.charAt(i) - 'a'];
            width += need;
            if(width > MAX_WIDTH){
                lines++;
                width = need;
            }
        }

        return new int[]{lines,width};

    }


}
